package io.renren.modules.truck.config;

import io.renren.common.utils.C;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.MultipartConfigElement;
import java.io.File;

@Configuration
public class UploadFileConfig {


    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        String uploadFolder = C.upload_windows;
        File tmpFile = new File(uploadFolder);
        if (!tmpFile.exists()) {
            tmpFile.mkdirs();
        }
        factory.setLocation(uploadFolder);

        //文件最大
        factory.setMaxFileSize("2000MB");
        // 设置总上传数据总大小
        factory.setMaxRequestSize("2000MB");
        return factory.createMultipartConfig();
    }
}
